﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using Negocio;
using Business.Entities;

namespace UI.Web
{
    public partial class Login : System.Web.UI.Page
    {
        UsuarioLogic ul;
        Usuario us;

        public Usuario Us
        {
            get { return us; }
            set { us = value; }
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnAceptar_Click(object sender, EventArgs e)
        {
            if (this.Validar())
            {
                ControladorSession ctrs = new ControladorSession(Us);
                Page.Response.Redirect("Menu.aspx");
            }
        }

         private bool Validar()
        {
           ul = new UsuarioLogic();
           Us = ul.LoguinUsuario(txtUsuario.Text, txtContraseña.Text);
            if (this.txtUsuario.Text == "" || this.txtContraseña.Text == "")
            {
                lblUser.Visible = true;
                lblpass.Visible = true;
                return false;
            }

            if (Us != null)
            {
                {
                    lblUser.Visible = false;
                    lblpass.Visible = false;
                    return true;

                }
            }
            else
            {
                lblUser.Visible = false;
                lblpass.Visible = false;
                Page.Response.Redirect("ErrorLogin.aspx");
                return false;
            }
        }
       
        }
}

